home *** CD-ROM | disk | FTP | other *** search
/ CU Amiga Super CD-ROM 6 / CU Amiga Magazine's Super CD-ROM 06 (1996)(EMAP Images)(GB)(Track 1 of 4)[!][issue 1997-01].iso / cucd / readers / utils / gui4cli / demos / cli.gc < prev    next >
Text File  |  1996-10-28  |  4KB  |  157 lines

  1. G4C     - 24/2/96 dck - GUI for Commands
  2.  
  3.  
  4. ; This GUI is similar to the Workbench "Execute command" GUI, but more.
  5. ; There is a textin gadget for entering commands, buttons for choosing
  6. ; files, changing the directory, and opening a newshell.
  7.  
  8. ; More important, it can also send ARexx commands to the port shown
  9. ; in the other (bottom right) textin gadget (which can also be changed)
  10.  
  11. ; On clicking the right mouse button an other GUI named "keyboard.g"
  12. ; is opened - It provides a letter pad to write commands using the
  13. ; mouse - not very useful, but pretty :)
  14.  
  15. ; Don't let the subroutine for this confuse you...
  16. ; It's nothing important and you will not need it in your own GUIs. 
  17.  
  18.  
  19. WinBig 10 30 520 38 "Enter commands :"
  20. WinSmall 0 -1 422 30
  21. WinType  11110010
  22.  
  23.  
  24. ; On loading, we set the default values of the variables & open window
  25.  
  26. xOnLoad
  27. ifexists variable gcMain        ; if a commandline has previously been set
  28.     ;                ; don't clear it
  29. else
  30.     setvar gcMain ""          ; Else, set & clear it.
  31. endif
  32. setvar gcMode G4C     ; Mode to run the command
  33. setvar gcPort Gui4Cli ; Name of default port (can also sendrexx to ourselves)
  34. setvar kbdGadID 1     ; ID of TEXTIN gadget to edit with the keyboard.g GUI
  35.  
  36. ; On opening we display the current directory in the titlebar (note large buffer)
  37.  
  38. xOnOpen
  39. setwintitle cli.gc "$$CURRENT_DIR                                  "
  40. Update cli.gc 1 $gcMain    ; show whatever the command line is 
  41. SetGad cli.gc 1 ON    ; to get the cursor in the gadget immediately
  42.  
  43. ; On quitting we delete the variables
  44.  
  45. xOnQuit
  46. delvar gcMain
  47. delvar gcMode
  48. delvar gcPort
  49. delvar gcEdit
  50.  
  51.  
  52. ;--------------------- On Right Mouse Button we open the keyboard.g GUI
  53. ; We must set 3 variables before opening it - read the GUI to understand
  54.  
  55. xOnRMB
  56. setvar kbdGui cli.gc
  57. if $kbdGadID < " "                      ; if 1st time
  58.    setvar kbdGadID 1                    ; set gad to 1
  59. endif
  60. if $kbdGadID = 1
  61.    setvar kbdBuffer gcMain              ; set kbdBuffer according to gadID
  62. else
  63.    setvar kbdBuffer gcEdit
  64. endif
  65. GuiLoad GUIs:demos/keyboard.g
  66. GuiOpen keyboard.g
  67.  
  68.  
  69. ;-------- 2 Radio buttons to let us choose the edit target
  70.  
  71. xRADIO 494 6 17 9 kbdGadID 9
  72. RSTR "" 1
  73. RSTR "" 2
  74. if $kbdGadID = 1
  75.    setvar kbdBuffer gcMain
  76.    setgad cli.gc 1 ON
  77. else
  78.    setvar kbdBuffer gcEdit
  79.    setgad cli.gc 2 ON
  80. endif
  81.  
  82.  
  83. ;================================> Main text input gadget
  84.  
  85. xTEXTIN 10 3 480 16 "" gcMain "" 512
  86. gadid 1
  87. gosub cli.gc DoCommand
  88.  
  89. ;========> Cycler for choosing ARexx/CLI/RUN modes
  90.  
  91. xCYCLER 10 20 80 14 "" gcMode
  92. GadID 10 ; we may want to change it from elsewhere
  93. CSTR ARexx     G4C
  94. CSTR CLI       CLI
  95. CSTR RUN       RUN
  96.  
  97. ;========> GO button (to execute the command)
  98.  
  99. xBUTTON 90 20 40 14 "GO!"
  100. gosub cli.gc DoCommand
  101.  
  102. ;========> Button for File requester for filenames (or commands)
  103.  
  104. xBUTTON 135 20 65 14 "Files.."
  105. setvar gcFile ""
  106. REQFILE -1 -1 300 -60 "Choose Files" MULTI gcFile  $$CURRENT_DIR
  107. if $gcFile > ""
  108.    appvar gcMain $gcFile
  109.    update cli.gc 1 $gcMain
  110. endif
  111.  
  112. ;========> Button to open a shell
  113.  
  114. xBUTTON 200 20 60 14 Shell
  115. CLI 'Newshell "con:0/150/640/100/NewShell/CLOSE"'
  116.  
  117. ;========> Button to change directory
  118.  
  119. xBUTTON 260 20 60 14 CD
  120. setvar gcDir ""
  121. REQFILE -1 -1 300 -60 "Choose directory" DIR gcDir ""
  122. if $gcDir > ""
  123.    CD $gcDir
  124.    SetWinTitle cli.gc "$gcDir                                        "
  125. endif
  126.  
  127. ;========> TEXTin gadget to get port name for sendrexx command
  128.  
  129. xTEXTIN 370 20 120 16 "Port" gcPort "Gui4Cli" 40
  130. GadID 2
  131.  
  132. ;========> ROUTINE to execute command
  133.  
  134. xROUTINE DoCommand
  135. docase $gcMode
  136. case  = G4C
  137.         SendRexx $gcPort $gcMain
  138.         SetWinTitle cli.gc "Rexx returned : $$RETCODE $$REXXRET            "
  139.         break
  140. case  = CLI
  141.         CLI $gcMain
  142.         SetWinTitle cli.gc "CLI Returned : $$RETCODE"
  143.         break
  144. case  = RUN
  145.         RUN $gcMain
  146.         SetWinTitle cli.gc "RUN Returned : $$RETCODE"
  147.         break
  148. endcase
  149.  
  150. ;=========> before commands are executed, we restore the window title
  151.  
  152. xBEFORE
  153. SetWinTitle cli.gc "$$CURRENT_DIR                           "
  154.  
  155.  
  156.  
  157.